package leetcode.题库.二叉树;

import leetcode.题库.pubclass.TreeNode;

/**
 * 二叉树的最大深度
 *
 * @author yanzhenming
 * @date 2023/4/16  3:26
 */
public class Solution104 {
    public int maxDepth(TreeNode root) {
        if (root == null) return 0;
        return maxDepth(root, 0);
    }

    public int maxDepth(TreeNode root, int deep) {
        if (root == null) return deep;
        return Math.max(maxDepth(root.left, deep + 1)
                , maxDepth(root.right, deep + 1));
    }
}
